home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / CDROM / MegaCdPlayer / ConvertCdIds.s < prev    next >
Encoding:
Text File  |  1997-05-09  |  11.7 KB  |  510 lines

  1. * Convert CDId's Files  to  New CdId MegaCdPlayer format
  2. * Remove's CdId's with Bad Total Cd Toc & 3rd Track Toc  Ie To Large Value's
  3.  
  4.         Machine    MC68020
  5.  
  6.         include /include/Wb_startup.i
  7.  
  8. start        jsr    openlibrarys
  9.         bsr    windopen
  10.  
  11. * Open Title File  (default header)
  12.         lea    DefSaveIndex,a0    
  13.         lea    MegaSaveTitle,a1    filename
  14.         move.l    #8,a2            size   (8 bytes)
  15.         jsr    savefile    
  16. * Open Index File  (default header)
  17.         lea    DefSaveIndex,a0            
  18.         lea    MegaSaveIndex,a1    filename
  19.         move.l    #16,a2            size   (16 bytes)
  20.         jsr    savefile
  21.         clr.l    NumberOfCds
  22.         clr.l    removedcds
  23.         clr.l    Skip01Count
  24.         lea    BadCdIdRemoved,a0
  25.         move    #10,d0    x
  26.         move    #30,d1    y
  27.         bsr    Print        Print No. of Bad Cdid removed
  28.         lea    Skip01Text,a0
  29.         move    #10,d0    x
  30.         move    #40,d1    y
  31.         bsr    Print        Print No. of Bad Cdid removed
  32.         
  33. * Get CdId directory using FileRequester
  34.         lea    CdIdReqTagList,a0
  35.         jsr    RequestersTagList  Get Disk/Directory  Using Req.
  36.         beq    Messageloop        Exit if Cancel selecte
  37.         lea    SaveDirBuffer,a0     Save Dir buffer Pt
  38.         move.l    #511,d0          Max size of buffer
  39.         jsr    SaveDirRequester    Save CdId Root Dir.
  40.         clr    SubDirNo
  41.  
  42.         
  43. NextDirectory    bsr    ReadDirectory
  44.         beq    Finished    If D0=0 Then Dir. not found, Finished
  45. .loop        bsr    ReadNext
  46.         beq    Finished    If D0=0 Then No more Files,  Finished
  47.         tst.l    d1
  48.         bpl.s    .loop        If D1=Plus Then is a Directory Skip
  49.         move.l    a0,a4        Save FileName Pt into A4
  50.  
  51. **        move.l    a4,a0
  52.         jsr    UseReqDirAddFile   Use Requester Directory & Add FileName
  53.         beq    Messageloop
  54. * Load CdId Text file  Cd Title, Author, Track Names
  55.         move.l    #0,a0        Set A0=0 Memory Allocated for file
  56.         move.l    d1,a1        File Name
  57.         jsr    loadfile
  58.         move.l    loadalcpt,temploadalcpt        save load Pt
  59.         move.l    a0,a5                save start pt
  60.         move.l    d0,d7                save size
  61.         
  62. * Make Cd Title & Aurthor Into one by taking out end Lf marker        
  63. .lfloop        cmp.b    #10,(a0)+
  64.         bne.s    .lfloop
  65.         move.b    #" ",-1(a0)    Replace with a Space
  66.  
  67.         move.l    a4,a0
  68.         bsr    ReadFileNameId    Read NoTracks,3rd Track Toc,Total Toc
  69.         beq.s    .isCdIdfile
  70.         add.l    #1,removedcds
  71.         move.l    removedcds,d0
  72.         bsr    HexDecConvert
  73.         move    #29*8+10,d0    x
  74.         move    #30,d1        y
  75.         bsr    Print        Print Number of Cd's Removed 
  76.         bra    .notCdIdfile
  77.  
  78. .isCdIdfile    move.l    a4,a0
  79.         move    #10,d0
  80.         move    #20,d1
  81.         bsr    Print        Print File Name
  82.  
  83.         
  84. * CdId files with "0" or "1" inbetween lines  remove the "1"'s
  85.  
  86.         moveq    #0,d2    "1" count
  87.         moveq    #-1,d3    line count  (-1 dont count title)
  88.         move.l    a5,a0
  89.         moveq    #0,d1
  90. .RemoveLoop    addq.l    #1,d1
  91.         cmp.l    d7,d1        If EndOfFile
  92.         bhi.s    .endfile
  93.         cmp.b    #10,(a0)+
  94.         bne.s    .RemoveLoop
  95. .LFfound    addq.l    #1,d3        inc line count
  96.         cmp.l    d7,d1        If lastchar of file
  97.         beq.s    .RemoveLoop    then goto Removeloop to end
  98.         cmp.b    #"0",(a0)    else Check if "0" char
  99.         beq.s    .is0
  100.         cmp.b    #"1",(a0)    or "1" char
  101.         bne.s    .RemoveLoop
  102. .is0        cmp.b    #10,1(a0)    and a LF char
  103.         bne.s    .RemoveLoop
  104.         addq.l    #1,d2        If is Then inc "0" "1" count
  105.         bra.s    .RemoveLoop
  106. .endfile    moveq    #0,d6        Clear Skip "1" Flag
  107.         cmp    d4,d2        if "1" count < number of tracks
  108.         blo.s    .NoSkip        then Noskip
  109.         lsr.l    #1,d3        linecount /2
  110.         cmp    d2,d3        if linecount < "1" count
  111.         blo.s    .NoSkip
  112.         
  113.         moveq    #1,d6        Set Skip "1" Flag
  114.         add.l    #1,Skip01Count
  115.         move.l    Skip01Count,d0
  116.         bsr    HexDecConvert
  117.         move    #29*8+10,d0    x
  118.         move    #40,d1        y
  119.         bsr    Print        Print Number of 
  120. .NoSkip        
  121.  
  122.  
  123. * count number of Track lines    (dont use any Extra lines)
  124. * and replace blank lines with a "*"
  125.  
  126.         lea    OutPutBuffer,a4
  127.         moveq    #0,d1        chars count
  128.         moveq    #0,d2        added chars count
  129.         move.l    a5,a0
  130. .countloop    addq.l    #1,d1
  131.         cmp.l    d7,d1        If EndOfFile
  132.         bhi.s    .notCdIdfile    then Error Dont used It  (to few tracks)
  133.         move.b    (a0),(a4)+    move to output buffer
  134.         cmp.b    #10,(a0)+
  135.         bne.s    .countloop
  136.  
  137. * Skip "0" or "1" lines if Flag set        
  138.         tst    d6        if Skip "1" Flag = 0
  139.         beq.s    .noskipcheck    then Dont Skip check
  140.         cmp.b    #"0",(a0)
  141.         beq.s    .yes0
  142.         cmp.b    #"1",(a0)    else Skip check
  143.         bne.s    .noskipcheck
  144. .yes0        cmp.b    #10,1(a0)
  145.         bne.s    .noskipcheck
  146.         add.l    #2,a0        skip "1" & Lf Char's
  147.         
  148. .noskipcheck    cmp.b    #10,-2(a4)    If BlankLine (IeĀ 2 LF's) 
  149.         bne.s    .notblankline
  150.         move.b    #"*",-1(a4)    put "*" in place of LF (BlankLine)
  151.         move.b    #10,(a4)+    then a LF
  152.         addq.l    #1,d2        inc added chars count
  153. .notblankline    dbf    d4,.countloop
  154.         move.b    #10,(a4)+    Put a LF at End
  155.         addq.l    #1,d2
  156.         add.l    d2,d1        add added chars count
  157.         move.l    d1,d7        set new File size
  158.  
  159.     
  160. * Add to Index file end        
  161.         move.l    #16,a2            size
  162.         lea    MegaSaveIndex,a1    fileName
  163.         lea    SaveIndexCdInfo,a0    mem pt
  164.         jsr    savetoend    - Save file to end
  165.         add.l    #1,NumberOfCds
  166.  
  167.  
  168. * Add to Title file End        
  169.         move.l    d7,a2            size
  170.         lea    MegaSaveTitle,a1    fileName
  171.         lea    OutPutBuffer,a0
  172.         jsr    savetoend    - Save file to end
  173.  
  174.  
  175. .notCdIdfile    move.l    temploadalcpt,loadalcpt        reload load pt
  176.         jsr    loadfreememory    free allocated memory used by file
  177.         bra    .loop
  178.  
  179. * load Index file so can update "Number of Cd's"
  180.  
  181. Finished    lea    SaveDirBuffer,a0     Save Dir buffer Pt
  182.         jsr    SetDirRequester        Set Directory to Root (as Saved)
  183.         add    #1,SubDirNo        Inc Dir No.
  184.         move    SubDirNo,d0
  185.         cmp    #99,d0            If SubDirNo > 99
  186.         bhi.s    .AllDoneNow        Then All Directorys Done
  187.         lea    CdIdSubDir,a0
  188.         Divul.l    #10,d1:d0        Else Convert SubDirNo to Ascii
  189.         addi.b    #$30,d0
  190.         move.b    d0,(a0)
  191.         addi.b    #$30,d1
  192.         move.b    d1,1(a0)
  193.         jsr    UseReqDirAddFile       Combine Sub Dir to Root Dir
  194.         move.l    d1,a0
  195.         jsr    SetDirRequester        Set to New Dir
  196.         bra    NextDirectory        Now do that directory
  197.  
  198. .AllDoneNow    lea    MegaSaveIndex,a1    fileName
  199.         move.l    #0,a0        Set A0=0 Memory Allocated for file
  200.         jsr    loadfile
  201.         move.l    loadalcpt,temploadalcpt        save load Pt
  202.         move.l    NumberOfCds,8(a0)
  203.             
  204.         lea    MegaSaveIndex,a1    filename
  205.         move.l    d0,a2            size
  206.         jsr    savefile        Save Index file back
  207.         move.l    temploadalcpt,loadalcpt        reload load pt
  208.         jsr    loadfreememory    free allocated memory used by file
  209.         
  210.         lea    Completedtext,a0
  211.         move    #10,d0
  212.         move    #100,d1
  213.         bsr    Print        Print all compleated
  214.  
  215.  
  216.         
  217. Messageloop    Bsr    WaitforMessage    
  218.         btst.l    #9,d3            if CloseWindow
  219.         beq.s    Messageloop
  220.  
  221. exit        bsr    windclose
  222.         jsr    closelibrarys
  223.         rts
  224.  
  225.  
  226. Lftext        dc.b    10,0
  227.         even
  228.  
  229. CdIdReqTagList    dc.l    ASL_Hail,CdIdReqHailpt
  230.         dc.l    ASL_Width,500
  231.         dc.l    ASL_Height,180
  232.         dc.l    ASL_Dir,CdIdReqDirpt
  233.         dc.l    ASL_ExtFlags1,%1    (no files shown)
  234.         dc.l    0
  235.  
  236. CdIdReqDirpt    dc.b "Work:CdIds",0
  237. CdIdReqHailpt    dc.b "Select CdId's Directory",0
  238.         even
  239.  
  240. * Cd Index File Format  (16 Bytes)
  241. DefSaveIndex    dc.b    "CD@0"        Header
  242.         dc.b    "V15",10    Version Number
  243. NumberOfCds    dc.l    0        Number of Cd's on list
  244.         dc.l    0        Total Number of Cds played (new for V1.5)
  245.  
  246. * New MegaCdPlayer Format saved with CdId's converted files
  247. *                New CdId's Format    MegaCdPlayer Format
  248. SaveIndexCdInfo    dc.l    0    3rd Track Toc        CdToc Last Track
  249.         dc.w    0    Number of Tracks    Number of Tracks
  250.         dc.l    0    Total Cd Toc        Not Used
  251.         dc.l    0    Played Count        Played Count
  252.         dc.w    "ID"    "ID"            Zero
  253.  
  254. Skip01Count    dc.l    0  Number of "0" or "1" in between tracknames skipped
  255. removedcds    dc.l    0  Number of CdId Removed
  256. BadCdIdRemoved    dc.b    "Number of Bad CdId Removed =",0
  257. Skip01Text    dc.b    "Number of '0' '1' Skipped  =",0
  258.         even
  259.  
  260. * Read Directory File Names        Call With  D1 - Pt to Directory to Read
  261.  
  262. ReadDirectory    move.l    dosbase,A6
  263. ***        move.l    #name,d1
  264.         move.l    #-2,d2
  265.         movea.l dosbase,A6
  266.         jsr    Lock(a6)
  267.         move.l    d0,locksav
  268.         beq.s    .exit        If D0=0 then Directory Not Found
  269.         move.l    dosbase,A6
  270.         move.l    locksav,d1
  271.         move.l    #fileinfo,d2    Pt to File Info Block (see P.152)
  272.         jsr    Examine(a6)    get file info
  273.         tst.l    d0
  274. .exit        rts            If D0=0  Then Error!
  275.  
  276.  
  277. ReadNext    move.l    dosbase,A6
  278.         move.l    locksav,d1
  279.         move.l    #fileinfo,d2
  280.         jsr    ExNext(a6)
  281.         tst.l    d0
  282.         beq.s    .exit
  283.         move.l    #fileinfo+8,a0        A0 Pt to File Name
  284.         move.l    fileinfo+4,d1        If D1 is Plus   =Directory
  285. .exit        rts                If D0 =0  Then No More files
  286.  
  287.  
  288. MegaSaveTitle    dc.b    "Ram:Title",0
  289.         even
  290. MegaSaveIndex    dc.b    "Ram:Index",0
  291.         even
  292.  
  293. SubDirNo    dc.w    0
  294. CdIdSubDir    dc.b    "01",0
  295.         even
  296.  
  297. SaveDirBuffer    ds.b    512
  298. OutPutBuffer    ds.b    100*99+100    Space for 99 track name + title
  299.         even
  300.  
  301. locksav        dc.l    0
  302. temploadalcpt    dc.l    0
  303.  
  304.  
  305.  
  306. * Read File Name CdId    "ID99ABCDEF123456
  307. *       Number Tracks -> ||
  308. *         3rd Track -> |----||----|  <- Total Cd Toc's
  309.  
  310. ReadFileNameId    lea    SaveIndexCdInfo,a2
  311.         cmp    #"ID",(a0)        Test If CdId File
  312.         beq.s    .isCdIdfile
  313. .notCdIdfile    moveq    #1,d0
  314.         rts
  315. .isCdIdfile    moveq    #0,d4
  316.         move.b    2(a0),d4        Number of tracks (x10)
  317.         sub.b    #"0",d4
  318.         mulu    #10,d4
  319.         move.b    3(a0),d0
  320.         sub.b    #"0",d0
  321.         add.b    d0,d4            Add unites
  322.         move    d4,4(a2)
  323.         
  324.         lea    4(a0),a1
  325.         bsr.s    .ConvertAsciiToHex
  326.         move.l    d2,(a2)            3rd Track Toc
  327.         cmp.l    #80*60*75,d2        Max = 80 mins x 60 x 75
  328.         bhi.s    .notCdIdfile        If >Max  Then Dont use
  329.         lea    10(a0),a1
  330.         bsr.s    .ConvertAsciiToHex
  331.         move.l    d2,6(a2)        Total Cd Toc
  332.         cmp.l    #80*60*75,d2        Max = 80 mins x 60 x 75
  333.         bhi.s    .notCdIdfile        If >Max  Then Dont use
  334.         cmp.l    (a2),d2        If Total Cd Toc < 3rd Track Toc
  335.         blo.s    .notCdIdfile    Then Dont use
  336. *testing
  337. *        cmp.l    #$025c65,d2
  338. *        bne.s    .nnn
  339. *        illegal
  340. *.nnn
  341.         moveq    #0,d0
  342.         rts
  343.         
  344. .ConvertAsciiToHex
  345.         moveq    #0,d2
  346.         moveq    #6-1,d1
  347. .loop        move.b    (a1)+,d0        read next character
  348.         sub.b    #"A",d0
  349.         bhs.s    .ischar
  350.         add.b    #7,d0
  351. .ischar        add.b    #10,d0            correct value 
  352.         lsl.l    #4,d2            shift left digit 
  353.         or.b    d0,d2            add digit
  354.         dbf    d1,.loop
  355.         rts
  356.  
  357.  
  358.  
  359.  
  360. Completedtext    dc.b    "Completed Convertion!    Click Close Window to exit",0
  361.         even
  362.  
  363.  
  364.  
  365.  
  366.  
  367. * * * Wait for Message * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  368. WaitforMessage    movem.l    A0-A1/A6,-(SP)
  369.         move.l  WindowHandle,a0
  370.         move.l    86(a0),a0    get user port pt
  371.         movea.l    4,A6
  372.         jsr    WaitPort(a6)    Wait for Message
  373.         move.l  WindowHandle,a0
  374.         move.l    86(a0),a0    get user port pt
  375.         jsr    GetMsg(a6)    Get Message
  376.         move.l    d0,a1
  377.         move.l    20(a1),d3    message type    d3= IDCMP  see AML p.175
  378.         move    24(a1),d4    Code specifier (char code etc)
  379.         move.l    28(a1),Iaddress
  380.         jsr    ReplyMsg(A6)    Reply Messsage
  381.         movem.l    (SP)+,A0-A1/A6
  382.         rts
  383.                 
  384. Iaddress    dc.l    0    Gadget Address
  385.         
  386.  
  387.  
  388. * Hex to Decimal Ascii    (uses 680020 Divul.l instruction)
  389. * D0 - Hex number
  390.  
  391. HexDecConvert    lea    dcharbuf,a0
  392. HexDecConvert2    moveq    #10-1,d2    10 digit number
  393. .loop        Divul.l    #10,d1:d0            (680020 Instruction)
  394.         addi.b    #$30,d1
  395.         move.b    d1,(a0,d2)
  396.         dbf    d2,.loop
  397. * do some left digit zero blanking
  398.         moveq    #10-1,d1          (dont blank last digit zero)
  399. .zloop        cmp.b    #$30,(a0)+
  400.         bne.s    .fin            skip over if zero 
  401.         dbf    d1,.zloop
  402. .fin        subq.l    #1,a0            correct a0        
  403.         rts
  404.  
  405. dcharbuf    ds.b 12
  406.         even
  407.  
  408.  
  409.  
  410.  
  411. * Print Text
  412.  
  413. * A0 - Pt to text to print
  414. * D0 - X pos  
  415. * D1 - Y pos
  416.  
  417. print        MOVEM.L    D0-D7/A0-A6,-(SP)
  418.         move.l    a0,printpt
  419.         lea    ptextcolour,a1
  420.         move.l    intuitionbase,a6
  421.         move.l    WindowHandle,a0
  422.         move.l    50(a0),a0
  423.         jsr    PrintIText(a6)
  424.         MOVEM.L    (SP)+,D0-D7/A0-A6
  425.         rts
  426.     
  427.  
  428. ptextcolour    dc.b    4,0    text,Background colour
  429.         dc.b    1    output mode
  430.         even
  431.         dc.w    0,0    x,y pos
  432. printfont    dc.l    0    font
  433. printpt        dc.l    0    text pt
  434.         dc.l    0    no more text
  435.     
  436.  
  437. windopen    move.l    Intuitionbase,a6
  438.         lea    windowdef,a0
  439.         jsr    openwindow(a6)
  440.         move.l    d0,WindowHandle
  441.         move.l    d0,a0
  442.         move.l    $2e(a0),screenhandle    Get Window's Screen Handle
  443.          rts                from Window Structure
  444.  
  445.  
  446. windclose    move.l    Intuitionbase,a6
  447.         move.l    WindowHandle,d0
  448.         beq.s    .exit
  449.         move.l    WindowHandle,a0
  450.         jsr    closewindow(a6)
  451. .exit        rts
  452.  
  453. ClearWindow    MOVEM.L    A6,-(SP)
  454.         moveq    #0,d0            X pos
  455.         moveq    #0,d1            Y pos
  456.         lea    _ClrWindowImage,a1
  457.         move.l    intuitionbase,a6
  458.         move.l    WindowHandle,a0
  459.         move.l    50(a0),a0        Rp
  460.         jsr    EraseImage(a6)        Erase Old Gadget Image
  461.         MOVEM.L    (SP)+,A6
  462.         rts
  463.  
  464. _ClrWindowImage    dc.w    4,11                x,y position
  465.         dc.w    600-4-18,250-11-2        width & height
  466.         dc.w    2
  467.         dc.l    0    (Image data not used)
  468.         dc.b    0,0
  469.         dc.l    0
  470.  
  471.  
  472.  
  473. windowdef    dc.w    10,20        x,y
  474.         dc.w    600,250        width & height
  475.         dc.b    0,1        print and background colours
  476.         dc.l    $200        IDCMP
  477.         dc.l    $100f
  478.         dc.l    0        Gadget pt
  479.         dc.l    0
  480.         dc.l    windname
  481.         dc.l    0    screenhd (Set to 0 for Workbench or public)
  482.         dc.l    0
  483.         dc.w    200,40,600,200
  484.         dc.w    $1         (1=Workbench Screen  2=Public Screen)
  485.  
  486. windname    dc.b    "Convert CdIds to MegaCdPlayer files format",0
  487.         even
  488. WindowHandle    dc.l    0
  489. screenhandle    dc.l    0    
  490.     
  491.     
  492. openwindow    equ    -204
  493. closewindow    equ    -72
  494. execbase    equ    4
  495. GetMsg        equ    -372
  496. ReplyMsg    equ    -378
  497. WaitPort    equ    -384
  498. DisplayBeep    equ    -96
  499. PrintIText    equ    -216
  500. EraseImage    equ    -630
  501.  
  502. CurrentDir        equ    -126
  503. SetCurrentDirName    equ    -558
  504. ExNext            equ    -108
  505.  
  506.  
  507.         include /include/Open_Close_All_Librarys
  508.         include /include/LoadFile2
  509.  
  510.